
import {commonAttr} from '../transfer'

const _componentsMap = {}
const requireComponent = import.meta.glob('./*/index.js')
let componentsArr = []
const _componentArr = []
Object.keys(requireComponent).forEach((path,index) => {
    const definition = requireComponent[path]
    componentsArr[index] = definition().then(component => {
        let arr = ['yc-btn-container','yc-web-table']
        if (arr.includes(component.default.componentName)) {
            _componentsMap[component.default.componentName] = component.default
        } else {
            // 在此处为所有输入框类组件添加公共属性
            // 组件内部属性值和公共属性有一样值时，以组件内部属性值优先
            _componentsMap[component.default.componentName] = {...commonAttr,...component.default}
        }
        _componentArr[index] = _componentsMap[component.default.componentName]
    })
})
export const loadCompnents =  Promise.all(componentsArr)
export const componentsMap =  _componentsMap
export const componentArr = _componentArr
